
#include "OgreApplication.h"

DebugBar::DebugBar(Ogre::RenderWindow *window){

	this->rend_wind		= window;
	this->counter		= 0;

	this->layoutName	= "DebugBar.layout";
	this->load();

	this->hide();
}

DebugBar::~DebugBar(){
	this->cegui_window->destroy();
}

void DebugBar::update(){
	if(this->shown && this->rend_wind != NULL){
		if(counter >= 20){
			
				float fps =  this->rend_wind->getAverageFPS();
                int tcount =  this->rend_wind->getTriangleCount();
                char* buffer1 = new char[30];
                
                sprintf(buffer1,"FPS: %f TriangleCount: %i",fps,tcount);
                
                std::string ret = buffer1;
                
                CEGUI::Editbox* box =(CEGUI::Editbox*) this->cegui_window->getChild("DebugBar/");
                box->setText(ret);
        
                delete [] buffer1;



			counter = 0;
		}
		else{
			counter ++;
		}
	}
}